#ifndef CPOKERCONNECTION_H
#define CPOKERCONNECTION_H

#include "progconn.h"
#include "cdbinterface.h"
#include "CaribbeanCommon.h"
#include "CaribbeanDefs.h"

class   CStudGame;
class   CStudHand;
class   Hand;
class   CGame;

// kharmon.  10-05-05.  #5861.  Changed class name.
class CPokerConnection : public ProgressiveConnection
{
    public:
        CPokerConnection(ProgressiveServer* server, SOCKET client);
        ~CPokerConnection();

        void msgStart();
        void msgAdd(uint8 Byte);
        void msgAdd(int32 SignedLong);
        uint8* msgGetBuf();
        void msgReleaseBuf(int32 Amt);
        void msgEnd();

        uint8   getPayTable() { return payTable; };
        uint8   getProgressivePayTable() { return progPayTable; };

        int32	getProgressiveFixedAmountMultiplier();
        void    setProgressiveFixedAmountMultiplier(int32 progressiveFixAmountMultiplier);

        void    SendWinMail(char *pcGameName, int32 win, int32 jackpotAmount);

        //  kharmon.  09-28-05.  #5861.  Provide access to the database interface
        //  for the current game.
        CDBInterface *getDBInterface() { return m_pDBInterface; }


        #ifdef FORCEDSHOE 
        String  GetPID() {return m_pid;}
        #endif

        


    protected:
        bool8    getResponse();

        //ProgressiveConnection abstract function required to be implemented by subclass
        virtual bool8 getForRealFlag();

        void    sendStopMsg();
        void    Answer( uint8 ans );
        void    Error( int err );

        bool8    parseAnsiCasinoLogin(int32*);
        bool8    parseUnicodeCasinoLogin(int32*);

        void    HandlePlayerAnsiLogin    ();    //Login
        void    HandlePlayerUnicodeLogin();    //login
        void    HandlePlayerLogin();

        int32    encode(uint8*, uint8*, int32);
        int32    decode(uint8*, uint8*, int32);

        int32    msgRemove(uint8*, int32*);

        bool    getOptions();

        //  kharmon.  09-28-05.  #5861.  Get a new game object for the indicated machine type
        CGame * getGame(CaribbeanGameId eGameID, int32 nBet, int32 nProgressiveBet);

        //  kharmon.  09-28-05.  #5861.  Get a new database interface object for the indicated machine type.
        CDBInterface * getDBInterface(CaribbeanGameId eGameID);

		// Flash server scalability
		void allocateXMLTranslator( XMLTranslator** target );

		// CSN-7075: New Authentication
		void trackLogoutSession();

    public:
        void    gameDone();

    protected:
        int32 loggedOn;
        int32 minBet, maxBet;
        int32 compFactor;
        int32 msglen;
        uint8 msgbuf[256];
        uint8 payTable, progPayTable;
		int32 progFixedAmountMultiplier;

        //  kharmon.  09-28-05.  #5861.
        CGame *game;                        // the current game object
        CInfo *m_pInfo;                     // information about the current game session
        CaribbeanGameId  m_eGameId;         // the type of game currently being played
        CDBInterface * m_pDBInterface;      // the database interface for the current game

        #ifdef FORCEDSHOE       //RPF 20100317 When forcing the shue now filter by pid
        String  m_pid;
        #endif

	// [AO 2008-01-16] Refactoring for HA
	private:
		bool ValidateSession();
};


inline 
int32
CPokerConnection::getProgressiveFixedAmountMultiplier()
{
	return progFixedAmountMultiplier;
}

#endif
